package tests.cases {
	
	import mx.rpc.AsyncToken;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.remoting.mxml.RemoteObject;
	
	import org.flexunit.Assert;
	
	import tests.cases.DefaultTestCase;
	
	public class TestLogout extends DefaultTestCase {
		
		private var coreSystemService:RemoteObject;
		
		[Before]
		public function setUp():void {
			
			coreSystemService = new RemoteObject();
			coreSystemService.destination = "amfphp";
			coreSystemService.source = "CoreSystemService";
		}
		
		[After]
		public function tearDown():void {
			
			coreSystemService = null;
		}
		
		// ----------------------------------------------------------------
		// TEST GOOD LOGOUT
		// ----------------------------------------------------------------
		[Test(async)]
		public function testGoodLogout():void {
			
			var argsVO:Object = {
				sessionID: "debug"
			};
			
			var token:AsyncToken = coreSystemService.logoutUser(argsVO.sessionID);
			runAsyncTest(token, argsVO, handleGoodLogoutSuccess);
		}
		
		private function handleGoodLogoutSuccess(message:ResultEvent, passedData:Object):void {
			
			Assert.assertNull(message.result);
		}
		
		// ----------------------------------------------------------------
		// TEST BAD LOGOUT
		// ----------------------------------------------------------------
		[Test(async)]
		public function testBadLogout():void {
			
			var argsVO:Object = {
				sessionID: null
			};
			
			var token:AsyncToken = coreSystemService.logoutUser(argsVO.email, argsVO.password);
			runAsyncTest(token, argsVO, handleBadLogoutSuccess);
		}
		
		private function handleBadLogoutSuccess(message:ResultEvent, passedData:Object):void {
			
			Assert.assertNull(message.result);
		}
	}
}